package com.juqimiao.outposts.spring.oauth2.api.configuration;


import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpHeaders;

import org.springframework.stereotype.Service;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;

import javax.servlet.http.HttpServletRequest;

/**
 * 配置oauth2服务跨域
 * @author collin
 * @date 2019/05/02
 */
@Service("CrossDomainCorsConfigurationSource")
public class CrossDomainCorsConfigurationSource implements CorsConfigurationSource {
    @Override
    public CorsConfiguration getCorsConfiguration(HttpServletRequest httpServletRequest) {

//        CorsConfiguration corsConfiguration = new CorsConfiguration();
//        corsConfiguration.addAllowedHeader("*");
//        corsConfiguration.addAllowedOrigin("*");
//       //corsConfiguration.addAllowedOrigin(httpServletRequest.getHeader(HttpHeaders.ORIGIN));
//        corsConfiguration.addAllowedMethod("*");
//        corsConfiguration.setAllowCredentials(true);
//        corsConfiguration.setMaxAge(3600L);
//        return corsConfiguration;
        return null;
    }
}
